﻿using UnityEngine;
using System.Collections;

public class ChangeScene : MonoBehaviour {

    private string sceneName;
    private GameObject texture;
    private float count;
    private float amount;
    private bool isRun;

    public void createFade(string sceneName, float amount)
    {
        this.sceneName = sceneName;

        this.amount = amount;
        texture = CreateTexture.getInstance().getTexture("FadeOut",Color.black,0);

        isRun = true;
    }

    public bool existFade()
    {
        return !isRun;
    }
    void Update()
    {

        if (isRun)
        {
            count += amount * Time.deltaTime;

            texture.guiTexture.color = new Color(0, 0, 0, count);

            if (count >= 0.6f)
            {
                Application.LoadLevel(sceneName);
            }
        }
    }
}
